package com.baitiaojun.common.utils.server;

import com.baitiaojun.common.utils.servlet.ServletUtils;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

public class ServerUtils {

    /**
     * 获取请求路径:域名+端口+上下文
     * @return
     */
    public static String getDomain() {
        HttpServletRequest request = ServletUtils.getRequest();
        StringBuffer requestURL = request.getRequestURL();
        ServletContext servletContext = request.getServletContext();
        return requestURL.delete((requestURL.length() - request.getRequestURI().length()), requestURL.length())
                .append(servletContext).toString();
    }
}
